<?php

/*	LibFox - Simple library for XML-based backends.
	Copyright (C) 2008 LinFox Serviços em Informática LTDA.

	This file is part of LibFox.

	LibFox is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	LibFox is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. */

class model
{
	public function xml_iterate($key_name = false)
	{
		if ($key_name) {
			$result = '<'.$key_name.'>';
		} else {
			$result = '';
		}

		foreach ($this as $key => $value)
		{
			if (!is_array($value) && !is_object($value))
			{
				$result .= '<'.str_underline($key).'>' .$value. '</'.str_underline($key).'>';
			}
		}
		
		if ($key_name) {
			$result .= '</'.$key_name.'>';
		}
 
		return $result;
	}
	
	public function get_request()
	{
		foreach ($this as $property => $value) {
			if ($var = get($property)) {
				$this->$property = $var;
			}
		}
	}
}

?>
